package demo1;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/25
 * Time: 19:13
 * Description:
 */
class Animal {
    public String name;

    public Animal(String name) {
        this.name = name;
    }

}
interface IRunning {
    void Running();
}
interface ISwimming {
    void swimming();
}

class Dog extends Animal implements IRunning,ISwimming{
    public Dog(String name) {
        super(name);
    }
    @Override
    public void Running() {
        System.out.println(this.name+"正在跑！");
    }
    @Override
    public void swimming() {
        System.out.println(this.name+"正在游泳！");
    }
}
class Cat extends Animal implements IRunning{

    public Cat(String name) {
        super(name);
    }
    @Override
    public void Running() {
        System.out.println(this.name+"正在跑！");
    }
}
class Fish extends Animal implements ISwimming{
    public Fish(String name) {
        super(name);
    }
    @Override
    public void swimming() {
        System.out.println(this.name+"正在游泳！");
    }
}
class Robot implements IRunning {

    @Override
    public void Running() {
        System.out.println("机器人在跑！");
    }
}
public class TestDemo {

    //只要实现了该接口的类  都可以传入
    public static void walk(IRunning iRunning) {
        iRunning.Running();
    }

    public static void main(String[] args) {
        walk(new Dog("元宝"));
        walk(new Cat("十三"));
        //walk(new Fish("十三"));
        walk(new Robot());
    }
}
